#include <iostream>
#include <vector>
using namespace std;

void insert(vector<vector<int>>& diff, int x1, int y1, int x2, int y2, int c)
{
    diff[x1][y1] += c;
    diff[x1][y2 + 1] -= c;
    diff[x2 + 1][y1] -= c;
    diff[x2 + 1][y2 + 1] += c;
}

int main()
{
    int n, m, q; cin >> n >> m >> q;
    vector<vector<int>> arr(n + 2, vector<int>(m + 2, 0));
    auto diff = arr;
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j)
        cin >> arr[i][j];
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j)
        // diff[i][j] = arr[i][j] - arr[i-1][j] - arr[i][j-1] + arr[i-1][j-1];
        insert(diff, i, j, i, j, arr[i][j]);
    while(q--)
    {
        int x1, y1, x2, y2, c; cin >> x1 >> y1 >> x2 >> y2 >> c;
        insert(diff, x1, y1, x2, y2, c);
    }
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= m; ++j)
        {
            diff[i][j] += diff[i - 1][j] + diff[i][j - 1] - diff[i - 1][j - 1];
            cout << diff[i][j] << ' ';
        }
        cout << endl;
    }
    
    return 0;
}